<?php


namespace api\blog\validate;


use think\Validate;

class DeliveryAddressValidate extends Validate
{
    //定义验证规则
    protected $rule = [
        'consignee' => 'require|max:10',
        'mobile' => 'require|mobile',
        'area' => 'require|max:25',
        'address' => 'require|max:100',
        'user_id' => 'require|integer',

    ];
    //定义验证失败时的提示信息
    protected $message = [
        'consignee.require' => '收货人不能为空',
        'consignee.max:10' => '收货人名字过长',
        'mobile.require' => '手机号不能为空',
        'mobile.mobile' => '手机号类型错误',
        'area.require' => '所在地区不能为空',
        'area.max:25' => '所在地区最大长度为25',
        'address.require' => '详细地址不能为空',
        'address.max:100' => '详细地址最大长度为100',
        'user_id.require' => 'id不能为空',
        'user_id.interge' => 'id参数错误',
    ];

    //验证场景
    protected  $scene = [
        'add' => ['consignee','mobile','area','address'],
        'edit' => ['id','consignee','mobile','area','address'],
    ];
}